<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%--用javabean取得現在時間再用jstl標籤轉為可用之格式 --%>
<jsp:useBean id="now" class="java.util.Date" scope="session" />
<fmt:formatDate var="today" value="${now }" pattern="yyyyMM"/>
<fmt:formatDate var="now_month" value="${now }" pattern="M"/>
<%--用javabean取得現在時間再用jstl標籤轉為可用之格式 --%>

<form action="index.jsp?f=15" method="post">
<table>
<caption><h1>查詢薪資</h1></caption>
<hr>
<tr><td>員工編號：</td><td>
<c:choose>
	<c:when test="${user_level == 1 }">
		<input type="text" name="user_id" value="${member.user_id }" />
	</c:when>
	<c:otherwise>
		<input type="hidden" name="user_id" value="${member.user_id }" />
		<c:out value="${member.user_id }" />
	</c:otherwise>
</c:choose>
</td></tr>
<input type="hidden" name="rightnow" value="${today }" />
</table>
<input type="submit" value="搜尋" />
</form>

<sql:query var="rs" dataSource="jdbc/j2db" >
	SELECT * 
	FROM overtime_hr oth, users u, month_salary ms 
	WHERE u.user_id = oth.user_id and ms.user_id = u.user_id 
	and  u.user_id = ? and ms.month = ?
	<sql:param>${param.user_id }</sql:param>
	<sql:param>${param.rightnow }</sql:param>
</sql:query>
<table>
	<tr>
		<th>${now_month-1 }月薪水</th>
		<th>${now_month }月補休剩餘總數(分鐘)</th>
	</tr>
<c:forEach var="r" items="${rs.rows}">
	<tr>
		<td>${r.msalary }</td>
		<td>${r.overtime_balance }</td>
	</tr>
</c:forEach>
</table>

<%--
<form action="salary" method="post">
<c:choose>
	<c:when test="${user_level == 1 }">
		員工編號：<input type="text" name="user_id" value="${member.user_id }" /><br>
	</c:when>
	<c:otherwise>
		<input type="hidden" name="user_id" value="${member.user_id }" /><br>
	</c:otherwise>
</c:choose>
<input type="hidden" name="rightnow" value="${today }" /><br>
<input type="submit" value="重新確認薪資" />
</form>
 --%>